package com.ruoyi.weixin.juc;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

/**
 * @Description: TODO
 * @Author ONESTAR
 * @Date: 2021/12/24 10:03
 * @Version 1.0
 */
// 测试线程池
public class TestPool {
    public static void main(String[] args) {
//        MyThread myThread = new MyThread();
//        new Thread(myThread).start();

        // 1 创建服务，创建线程池
        ExecutorService service = Executors.newFixedThreadPool(10);
        service.execute(new MyThread());
        service.execute(new MyThread());
        service.execute(new MyThread());
        service.execute(new MyThread());

        // 2 关闭链接
        service.shutdownNow();
    }

}

class MyThread implements Runnable {
    @Override
    public void run() {

        System.out.println(Thread.currentThread().getName());


//        for (int i = 0; i < 100; i++) {
//            System.out.println(Thread.currentThread().getName() + i);
//        }
    }
}
